from user import user_login, user_charge, user_pay
from flask import make_response
from utils import utils


class UserController:
    @staticmethod
    def user_url(app):
        @app.route("/api/hello", methods=["GET"])
        def hello():
            return make_response({"ok": True, "data": "Hello"})

        @app.route("/api/login", methods=["POST"])
        def login():
            login_res = user_login.UserLogin.get_login()
            return login_res

        @app.route("/api/register", methods=["POST"])
        def register():
            register_res = user_login.UserLogin.get_register()
            return register_res

        @app.route("/api/password", methods=["POST"])
        def password():
            password_res = user_login.UserLogin.set_password()
            return password_res

        @app.route("/api/send_appoint", methods=["POST"])
        def send_appoint():
            send_appoint_res = user_charge.UserCharge.send_appointment()
            utils.print_charge_queue()
            utils.print_wait_queue()
            return send_appoint_res

        @app.route("/api/change_appoint", methods=["POST"])
        def change_appoint():
            change_appoint_res = user_charge.UserCharge.change_appointment()
            utils.print_charge_queue()
            utils.print_wait_queue()
            return change_appoint_res

        @app.route("/api/cancel_appoint", methods=["POST"])
        def cancel_appoint():
            cancel_appoint_res = user_charge.UserCharge.cancel_appointment()
            utils.print_charge_queue()
            utils.print_wait_queue()
            return cancel_appoint_res

        @app.route("/api/get_where", methods=["POST"])
        def get_where():
            get_where_res = user_charge.UserCharge.get_where()
            return get_where_res

        @app.route("/api/get_state", methods=["POST"])
        def get_state():
            get_state_res = user_charge.UserCharge.get_state()
            return get_state_res

        @app.route("/api/get_front_num", methods=["POST"])
        def get_front_num():
            get_front_num_res = user_charge.UserCharge.get_front_number()
            return get_front_num_res

        @app.route("/api/get_wait_label", methods=["POST"])
        def get_wait_label():
            get_wait_label_res = user_charge.UserCharge.get_wait_label()
            return get_wait_label_res

        @app.route("/api/get_balance", methods=["POST"])
        def get_balance():
            get_balance_res = user_pay.UserPay.get_balance()
            return get_balance_res

        @app.route("/api/inc_balance", methods=["POST"])
        def inc_balance():
            inc_balance_res = user_pay.UserPay.inc_balance()
            return inc_balance_res

        @app.route("/api/pay_order", methods=["POST"])
        def pay_order():
            pay_order_res = user_pay.UserPay.pay_order()
            utils.print_charge_queue()
            utils.print_wait_queue()
            return pay_order_res

        @app.route("/api/get_order", methods=["POST"])
        def get_order():
            get_order_res = user_pay.UserPay.get_order()
            return get_order_res

        @app.route("/api/print", methods=["POST"])
        def user_print():
            utils.print_charge_queue()
            utils.print_wait_queue()

            return make_response({"ok": True})


